Monday 10 October 2022

Conditional Operator in C++, C Language |Tarnary Operator in C, C++ |What is Conditional Operator in Programming Language |What is Operator. in programming language |What is Operator in C, C++ |Types of Operator. in Programming Language, C, C++

      - : CONDITIONAL or TARNARY OPERATOR :-


   Operators are those symbols which are used between operands to perform Mathematical and Logical operations. 

    Conditional Operator is similar to the if_else Statement. We Can say that conditional operator is the sorter manner of writing if_else Statement.

    Conditional Operator include 2 following symbols -

    [?, :]

    For Example, we take 2 variables X=5 and Y=7. Now creating a condition X>Y. Let's see how it works - 

X>Y ? X is Greater : Y is Greater 

 let's understand what happened, we gave a conditional X>Y, but we can see X is actually not equal to Y. So (?) symbol means it checks the given condition is true or not and if condition is true, performs operation which is given. if condition is not true(means False) then performs another operation whatever is given. 

    In short, (?) works as if and (:) works as else

   __________________________________________________________

 A program to understand the Conditional Operator 

#include<iostream>

using namespace std ;

int main() {

      int X=5, Y=7;

(X>Y)?cout<<"X is greater than Y" :cout<<"Y is greater than X" ;

    return 0 ;

__________________________________________________________

Output :-

Y is greater than X

__________________________________________________________


MUST READ :-


What is Operator in Programming Language 

What is Arithmetic Operator in Programming Language 

What is Relational Operator in C, C++ programming languages 

What is Logical Operators in C, C++ Programming Language (English Explanation

What is Logical Operator in C, C++ Language (Hindi Explanation) 

What is Bitwise Operator in C, C++0

increment Decrement Operators in Programming Language 

___________________________________________________

What is Function in programming language 


What is Function in programming language (Hindi Explanation

___________________________________________________

What is Class in Programming language 


What is Class in Programming language (Hindi Explanation









No comments:

Post a Comment